package com.shuzijun.leetcode.editor.cn;
public class ShuZuZhongShuZiChuXianDeCiShuLcof{
    public static void main(String[] args) {
         Solution solution = new ShuZuZhongShuZiChuXianDeCiShuLcof().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int[] singleNumbers(int[] nums) {
        int xorResult = 0;
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            xorResult ^= nums[i];
        }

        int tag = 1;
        while ((xorResult&tag) == 0){
            tag = tag <<1;
        }
        int a = 0;
        int b = 0;
        for (int i = 0; i < n; i++) {
            if ((nums[i] & tag) == 0){
                a ^= nums[i];
            }else {
                b ^= nums[i];
            }
        }
        return new int[]{a,b};
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}